#include <bits/stdc++.h>

using namespace std;

const int N = 4e5 + 5;
const long long lim = 1e12;
int rt;

struct segmentTree {
	static const int SN = N << 6;
	int tot, ch[SN][2], siz[SN]; 
	long long sum[SN];
	
	#define ls(x) (ch[x][0])
	#define rs(x) (ch[x][1]) 
	
	void push_up(int x) {
		siz[x] = siz[ls(x)] + siz[rs(x)];
		sum[x] = sum[ls(x)] + sum[rs(x)];
	}
	
	void modify(long long P, int &x = rt, long long l = 1, long long r = lim) {
		if (!x) x = ++tot; 
		if (l == r) return siz[x] ^= 1, sum[x] = siz[x] * l, void();
		long long mid = (l + r) >> 1;
		P <= mid ? modify(P, ls(x), l, mid) : modify(P, rs(x), mid + 1, r);
		push_up(x);
	}
	
	long long queryL(int k, int x = rt, long long l = 1, long long r = lim) {
		if (l == r) return l;
		long long mid = (l + r) >> 1;
		if (siz[ls(x)] >= k) return queryL(k, ls(x), l, mid);
		else return sum[ls(x)] + queryL(k - siz[ls(x)], rs(x), mid + 1, r) ;
	}
	
	long long queryR(int k, int x = rt, long long l = 1, long long r = lim) {
		if (l == r) return l;
		long long mid = (l + r) >> 1;
		if (siz[rs(x)] >= k) return queryR(k, rs(x), mid + 1, r);
		else return sum[rs(x)] + queryR(k - siz[rs(x)], ls(x), l, mid); 
	}
} smt;

signed main() {

	freopen("kte.in", "r", stdin);
	froepen("kte.out", "w", stdout);

	ios::sync_with_stdio(false), cin.tie(nullptr);
	
	int T;
	cin >> T;
	while (T--) {
		long long x;
		cin >> x;
		smt.modify(x);
		long long ans = 0, mx = 0, last = 0;
		for (int i = 1; i <= smt.siz[1]; i++) {
			long long l = smt.queryL(i), r = smt.queryR(i);
			r--;
			if (l > r) continue;
			mx = r;
			if (l > last) ans -= l - last - 1;
			last = r;
		}
		ans += mx;
		cout << ans << "\n";
	}

	return 0;
}

